/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.DynamoBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class DynamoDAO
/*     */ {
/*  23 */   private static final Log log = LogFactory.getLog(DynamoDAO.class);
/*     */ 
/*  25 */   private dbConnector dbcon = null;
/*  26 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*  27 */   private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*     */ 
/*     */   private void dbConInit() {
/*  30 */     if (this.dbcon == null)
/*  31 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  35 */     if (this.dbcon != null)
/*  36 */       this.dbcon.closeAll();
/*  37 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getDynamoList(Map condition)
/*     */   {
/*  42 */     ListContentsBFO bfo = new ListContentsBFO();
/*  43 */     int start = Integer.parseInt(condition.get("start").toString());
/*  44 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  45 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  46 */     ResultSet rs = null;
/*  47 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  50 */       dbConInit();
/*     */ 
/*  52 */       Object objRegistBeginTime = condition.get("registBeginTime");
/*  53 */       Object objRegistEndTime = condition.get("registEndTime");
/*  54 */       String strSQL = " select count(id) from dynamo where btscode = '" + strBtscode + "' ";
/*  55 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/*  56 */       log.info(strSQL);
/*  57 */       rs = this.dbcon.execQuery(strSQL);
/*  58 */       if (rs.next()) {
/*  59 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  61 */       strSQL = " select * from dynamo where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  62 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/*  63 */       log.info(strSQL);
/*  64 */       rs = this.dbcon.execQuery(strSQL);
/*  65 */       while (rs.next()) {
/*  66 */         DynamoBO bo = new DynamoBO();
/*  67 */         bo.setId(rs.getString("id"));
/*  68 */         bo.setBtscode(rs.getString("btscode"));
/*  69 */         bo.setBtsname(rs.getString("btsname"));
/*  70 */         bo.setManufacturer(rs.getString("manufacturer"));
/*  71 */         bo.setType(rs.getString("type"));
/*  72 */         bo.setModel(rs.getString("model"));
/*  73 */         bo.setPower(rs.getString("power"));
/*  74 */         bo.setAutoboot(rs.getString("autoboot"));
/*  75 */         bo.setConsumption(rs.getString("consumption"));
/*  76 */         bo.setSumtime(rs.getString("sumtime"));
/*  77 */         bo.setMaintenance(rs.getString("maintenance"));
/*  78 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  79 */         bo.setMemo(rs.getString("memo"));
/*  80 */         bo.setDynamoIsStatic(rs.getString("dynamoIsStatic"));
/*  81 */         bo.setDanymoSeiral(rs.getString("danymoSeiral"));
/*  82 */         bo.setDynamoWorkLen(rs.getString("dynamoWorkLen"));
/*  83 */         bo.setDynamoMaintainRec(rs.getString("dynamoMaintainRec"));
/*  84 */         bo.setDynamoHouse(rs.getString("dynamoHouse"));
/*  85 */         list.add(bo);
/*     */       }
/*  87 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  90 */       e.printStackTrace();
/*  91 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  94 */       dbConClose();
/*     */     }
/*  96 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveDynamo(DynamoBO bo)
/*     */   {
/* 101 */     log.info("添加--发电机组---开始");
/* 102 */     boolean flag = true;
/*     */     try
/*     */     {
/* 105 */       dbConInit();
/* 106 */       StringBuffer sqlBuf = new StringBuffer();
/* 107 */       sqlBuf.append(" insert into dynamo ( btscode, btsname, manufacturer,  type, model, ");
/* 108 */       sqlBuf.append(" power, autoboot,  consumption, sumtime,  maintenance, refreshtime,");
/* 109 */       sqlBuf.append(" memo, dynamoIsStatic, danymoSeiral, dynamoWorkLen, dynamoMaintainRec,registtime,dynamoHouse ) values ( ");
/* 110 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/* 111 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 112 */       sqlBuf.append(" '" + bo.getManufacturer() + "' ,");
/* 113 */       sqlBuf.append(" '" + bo.getType() + "' ,");
/* 114 */       sqlBuf.append(" '" + bo.getModel() + "' ,");
/* 115 */       sqlBuf.append(" '" + bo.getPower() + "' ,");
/* 116 */       sqlBuf.append(" '" + bo.getAutoboot() + "' ,");
/* 117 */       sqlBuf.append(" '" + bo.getConsumption() + "' ,");
/* 118 */       sqlBuf.append(" '" + bo.getSumtime() + "' ,");
/* 119 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 120 */       sqlBuf.append(" '" + this.sdf.format(new Date()) + "' ,");
/* 121 */       sqlBuf.append(" '" + bo.getMemo() + "' ,");
/* 122 */       sqlBuf.append(" '" + bo.getDynamoIsStatic() + "' ,");
/* 123 */       sqlBuf.append(" '" + bo.getDanymoSeiral() + "' ,");
/* 124 */       sqlBuf.append(" '" + bo.getDynamoWorkLen() + "' ,");
/* 125 */       sqlBuf.append(" '" + bo.getDynamoMaintainRec() + "' ,");
/* 126 */       sqlBuf.append(" '" + this.open.format(new Date()) + "' ,");
/* 127 */       sqlBuf.append(" '" + bo.getDynamoHouse() + "' )");
/* 128 */       log.info(sqlBuf.toString());
/* 129 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 133 */       flag = false;
/* 134 */       e.printStackTrace();
/* 135 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 138 */       dbConClose();
/*     */     }
/* 140 */     log.info("添加--发电机组---结束");
/* 141 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateDynamo(DynamoBO bo)
/*     */   {
/* 147 */     log.info("修改--发电机组---开始");
/* 148 */     boolean flag = true;
/*     */     try
/*     */     {
/* 151 */       dbConInit();
/* 152 */       StringBuffer sqlBuf = new StringBuffer();
/* 153 */       sqlBuf.append(" update dynamo set ");
/* 154 */       sqlBuf.append(" manufacturer = '" + bo.getManufacturer() + "' ,");
/* 155 */       sqlBuf.append(" type = '" + bo.getType() + "' ,");
/* 156 */       sqlBuf.append(" model = '" + bo.getModel() + "' ,");
/* 157 */       sqlBuf.append(" power = '" + bo.getPower() + "' ,");
/* 158 */       sqlBuf.append(" autoboot = '" + bo.getAutoboot() + "' ,");
/* 159 */       sqlBuf.append(" consumption = '" + bo.getConsumption() + "' ,");
/* 160 */       sqlBuf.append(" sumtime = '" + bo.getSumtime() + "' ,");
/* 161 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 162 */       sqlBuf.append(" refreshtime = '" + this.sdf.format(new Date()) + "' ,");
/* 163 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ,");
/* 164 */       sqlBuf.append(" dynamoIsStatic = '" + bo.getDynamoIsStatic() + "' ,");
/* 165 */       sqlBuf.append(" danymoSeiral = '" + bo.getDanymoSeiral() + "' ,");
/* 166 */       sqlBuf.append(" dynamoWorkLen = '" + bo.getDynamoWorkLen() + "' ,");
/* 167 */       sqlBuf.append(" dynamoHouse = '" + bo.getDynamoHouse() + "' ,");
/* 168 */       sqlBuf.append(" dynamoMaintainRec = '" + bo.getDynamoMaintainRec() + "' ");
/* 169 */       sqlBuf.append(" where id = '" + bo.getId() + "'");
/* 170 */       log.info(sqlBuf.toString());
/* 171 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 175 */       flag = false;
/* 176 */       e.printStackTrace();
/* 177 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 180 */       dbConClose();
/*     */     }
/* 182 */     log.info("修改--发电机组---结束");
/* 183 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteDynamo(String strID)
/*     */   {
/* 188 */     log.info("删除--发电机组---开始");
/* 189 */     boolean flag = true;
/*     */     try
/*     */     {
/* 192 */       dbConInit();
/* 193 */       StringBuffer sqlBuf = new StringBuffer();
/* 194 */       sqlBuf.append(" delete from  dynamo ");
/* 195 */       sqlBuf.append(" where id = '" + strID + "'");
/* 196 */       log.info(sqlBuf.toString());
/* 197 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 201 */       flag = false;
/* 202 */       e.printStackTrace();
/* 203 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 206 */       dbConClose();
/*     */     }
/* 208 */     log.info("删除--发电机组---结束");
/* 209 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getDynamoByBtsName(Map condition)
/*     */   {
/* 215 */     ListContentsBFO bfo = new ListContentsBFO();
/* 216 */     int start = Integer.parseInt(condition.get("start").toString());
/* 217 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 218 */     String strBtsName = condition.get("btsName").toString();
/* 219 */     ResultSet rs = null;
/* 220 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 223 */       dbConInit();
/* 224 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 225 */       Object objRegistEndTime = condition.get("registEndTime");
/* 226 */       String strSQL = " select count(id) from dynamo where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%') ";
/* 227 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 228 */       log.info(strSQL);
/* 229 */       rs = this.dbcon.execQuery(strSQL);
/* 230 */       if (rs.next()) {
/* 231 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 233 */       strSQL = " select * from dynamo where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 234 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 235 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 236 */       log.info(strSQL);
/* 237 */       rs = this.dbcon.execQuery(strSQL);
/* 238 */       while (rs.next()) {
/* 239 */         DynamoBO bo = new DynamoBO();
/* 240 */         bo.setId(rs.getString("id"));
/* 241 */         bo.setBtscode(rs.getString("btscode"));
/* 242 */         bo.setBtsname(rs.getString("btsname"));
/* 243 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 244 */         bo.setType(rs.getString("type"));
/* 245 */         bo.setModel(rs.getString("model"));
/* 246 */         bo.setPower(rs.getString("power"));
/* 247 */         bo.setAutoboot(rs.getString("autoboot"));
/* 248 */         bo.setConsumption(rs.getString("consumption"));
/* 249 */         bo.setSumtime(rs.getString("sumtime"));
/* 250 */         bo.setMaintenance(rs.getString("maintenance"));
/* 251 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 252 */         bo.setMemo(rs.getString("memo"));
/* 253 */         bo.setDynamoIsStatic(rs.getString("dynamoIsStatic"));
/* 254 */         bo.setDanymoSeiral(rs.getString("danymoSeiral"));
/* 255 */         bo.setDynamoWorkLen(rs.getString("dynamoWorkLen"));
/* 256 */         bo.setDynamoMaintainRec(rs.getString("dynamoMaintainRec"));
/* 257 */         bo.setDynamoHouse(rs.getString("dynamoHouse"));
/* 258 */         list.add(bo);
/*     */       }
/* 260 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 263 */       e.printStackTrace();
/* 264 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 267 */       dbConClose();
/*     */     }
/* 269 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 274 */     ResultSet rs = null;
/* 275 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 278 */       dbConInit();
/* 279 */       String strSQL = " select * from dynamo where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 280 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 281 */       log.info(strSQL);
/* 282 */       rs = this.dbcon.execQuery(strSQL);
/* 283 */       while (rs.next()) {
/* 284 */         DynamoBO bo = new DynamoBO();
/* 285 */         bo.setId(rs.getString("id"));
/* 286 */         bo.setBtscode(rs.getString("btscode"));
/* 287 */         bo.setBtsname(rs.getString("btsname"));
/* 288 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 289 */         bo.setType(rs.getString("type"));
/* 290 */         bo.setModel(rs.getString("model"));
/* 291 */         bo.setPower(rs.getString("power"));
/* 292 */         bo.setAutoboot(rs.getString("autoboot"));
/* 293 */         bo.setConsumption(rs.getString("consumption"));
/* 294 */         bo.setSumtime(rs.getString("sumtime"));
/* 295 */         bo.setMaintenance(rs.getString("maintenance"));
/* 296 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 297 */         bo.setMemo(rs.getString("memo"));
/* 298 */         bo.setDynamoIsStatic(rs.getString("dynamoIsStatic"));
/* 299 */         bo.setDanymoSeiral(rs.getString("danymoSeiral"));
/* 300 */         bo.setDynamoWorkLen(rs.getString("dynamoWorkLen"));
/* 301 */         bo.setDynamoMaintainRec(rs.getString("dynamoMaintainRec"));
/* 302 */         bo.setDynamoHouse(rs.getString("dynamoHouse"));
/* 303 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 307 */       e.printStackTrace();
/* 308 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 311 */       dbConClose();
/*     */     }
/* 313 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.DynamoDAO
 * JD-Core Version:    0.6.2
 */